<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>

<head>
<title>Setup Payee</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>"></script>
</head>

<body>
<div class="page"><%@include file="../top_menu.jsp"%><table width=100%>
	<tr>
		<td><c:import url="/WEB-INF/jsp/menu/payee_menu.jsp" /></td>
	</tr>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>

</table>
 
<div class="contentArea"><form:form commandName="managePayee"
	method="post">
	<table width=90% class="formTable">

		<tr class="formHeader">
			
			<td colspan="2">Payee List</td>
		</tr>
		<tr>
			<td colspan="2"><c:choose>
			<c:when test="${empty managePayee.payeesList}">
			
			No payee found, please click <a href="<c:url value="/serviceprovider/payee/create_payee.htm" />">here </a>to create a payee.
			</c:when><c:otherwise>
			<table border=1 cellpadding=0 cellspacing=0 width=100%>
				<tr bgcolor="#E9E9E9">
					<td><b>#</b></td>
					<td><b>Full name</b></td>
					<td><b>Email</b></td>
					<td><b>Role</b></td>
					<td><b>Profile</b></td>
					<td><b>Active</b></td>
					<td><b>Delete</b></td>
					<td><b>Show GUI</b></td>
				</tr>
				
				<c:forEach items="${managePayee.payeesList}" var="payee"
					varStatus="i">
					<tr <c:if test="${payee.deleted==true}"> bgcolor="gray"</c:if>>
						<form:hidden path="payeesList[${i.index}].id" />
						<td>${i.index+1}</td>
						<td>${payee.profile.firstName } ${payee.profile.lastName }</td>
						<td>${payee.email }</td>

						<td>${payee.role.name }</td>

						<td><c:if test="${payee.deleted==false}">
							<c:if test="${payee.profile == null}">
								<a href="create_payee_profile.htm?payeeId=${payee.id}">Create
								Profile</a>
							</c:if>
							<c:if test="${payee.profile != null}">
								<a href="update_payee_profile.htm?payeeId=${payee.id}">Update
								Payee Profile</a>
							</c:if>
						</c:if></td>
						<!--	    				<td><a href="update_payee.htm?payeeId=${payee.id}">Update Payee Management</a></td>-->

						<td><form:checkbox path="payeesList[${i.index}].enabled"
							disabled="${payee.deleted}" /> <!--	    					<c:if test="${payee.enabled == false}">False</c:if>-->
						<!--	    					<c:if test="${payee.enabled == true}">True</c:if>-->
						</td>
						<td><form:checkbox path="payeesList[${i.index}].deleted" /></td>
						<td><form:checkbox path="payeesList[${i.index}].showGui"
							disabled="${payee.deleted}"
							onclick="checkboxlimit(${fn:length(managePayee.payeesList)}, 4)" /></td>

					</tr>
				</c:forEach>
				
				<tr>
			<td colspan="6">
			<p><font color="Green"> To activate / delete a user,
			please check the box. Un-check to Deactivate / Undo Delete. Delete
			will make the user invisible on the rest of the GUI except this
			screen. All deleted users will show up as grayed out on this screen .
			</font></p>
			</td>
		</tr>
		<tr>
			<td colspan="6"><input type="submit" class='ui-button ui-state-default ui-corner-all' id="updatePayeeList"
				value="Update" /></td>
		</tr>
			</table></c:otherwise>
			</c:choose>
			</td>
		</tr>
		
	</table>
</form:form></div>
<script type="text/javascript">

/***********************************************
* Limit number of checked checkboxes script
* 
***********************************************/
var count=0;
<c:forEach var="i" begin="0" end="${fn:length(managePayee.payeesList)}" step="1" >

	<c:if test="${managePayee.payeesList[i].showGui==true}">count++</c:if>
</c:forEach>
function checkboxlimit(length, limit){
	
	var id;
	
		if(this.checked){
			count++;
		}
		else{
			count--;
		}
		
	
	if(count>limit){
		alert("You can only select a maximum of "+limit+" users to be shown in transaction page")
		this.checked=false
	}	

}

</script></div>
 <%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>